<?php
	include('../include/includeFiles1.php');
	include('checklogin.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<link href="style/style_main.css" rel="stylesheet" type="text/css" />
<head>
<?php
	include('./include/meta.php');
?>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
  <?php include("./header.php"); ?>
  <?

if($_SESSION['M_Id']==""){
	echo "<script>alert('请先登录');location.href='member_info.php';</script>";
	exit;
}


$action=$_POST["action"];
if($action=="edit"){
	$sql="select * from hy_member where user_id='".$_SESSION["M_Id"]."' and user_pws='$oldpwd'";
	$objDb->query($sql);
	$row=$objDb->get_data();
	if(!$row){
		echo "<script>alert('旧密码错误，请重新输入。');location.href='Member_editpwd.php';</script>";
		exit;
	}
	$sql="update hy_member set `user_pws`='$user_pws' where user_id='$user_id'";
	$result=$objDb->query($sql);
	if($result){
		echo "<script>alert('修改成功。');location.href='Member_editpwd.php';</script>";
		exit;
	}
	else{
		echo "<script>alert('修改失败，请重试。');history.go(-1);</script>";
		exit;
	}
}

$sql="select * from `hy_b_member` where `MemberID`='".$_SESSION["M_Id"]."'";
//echo $sql;
//die;
$objDb->query($sql);
$row=$objDb->get_data();
if($row){

	$struserid=$row[0]["user_id"];
	$strusername=$row[0]["PerlName"];
	$strusertruename=$row[0]["user_truename"];
	$struserpws=$row[0]["user_pws"];
	$strusersex=$row[0]["user_sex"];
	$struseremail=$row[0]["PerlEmail"];
	$struserzipcode=$row[0]["user_zipcode"];
	$struseradd=$row[0]["CmpAddress"];
	$strusertel=$row[0]["PerlPhone"];
	$strusermobile=$row[0]["user_mobile"];
	$strusercompany=$row[0]["user_company"];
	$struserintro=$row[0]["user_intro"];
}

?>
  <script type="text/javascript">
<!--
function EditCar(s,p){
	var buyNum=document.getElementById("buyNum"+s).value;
	if(isNaN(buyNum) || buyNum.indexOf('.')!=-1){
		alert('数量必须为整数');
		document.getElementById("buyNum"+s).focus();
		return false;
	}
	else{
		location.href="?bn="+buyNum+"&id="+s+"&price="+p+"&action=edit";
	}
}
-->
</script>
  <table width="957" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td height="199" style="background:url(images/member_banner.jpg) no-repeat"><div style="height:167px; overflow:hidden;">
          <script language=javascript>
var flashURL="images/fen_banner.swf";
var flashWIDTH="956";   
var flashHEIGHT="167"; 
</script>
          <script language=javascript src="flash_view.js"></script>
        </div></td>
    </tr>
  </table>
  <table width="957" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td width="210" height="207" valign="top"><table width="210" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/member_t.jpg" width="210" height="28" /></td>
          </tr>
          <tr>
            <td height="150" valign="top" class="menu"><?php include('left_list.php');?></td>
          </tr>
          <tr>
            <td><?php include("left_box.php"); ?></td>
          </tr>
          <tr>
            <td><img src="images/menu_dig.jpg" width="210" height="25" /></td>
          </tr>
        </table></td>
      <td valign="top"><div class="fen_title"><span>您的订票纪录</span>您的位置：<a href="main.php">首页</a>>><a href="member.php"> 会员中心</a>>> 会员订/购票查询</div>
        <table width="600" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="28"><form name="form1" method="post" action="flight.php">
                <div align="center"><strong>航班查找</strong>：航班日期
                  <input name="fbtime" type="text" id="fbtime" size="15" class="input" maxlength="25" value="2009-12-12">
                  &nbsp;&nbsp;
                  <input type="submit" name="Submit" value="查看">
                </div>
              </form></td>
          </tr>
          <tr>
            <td height="1" background="image/line2.jpg"></td>
          </tr>
          <tr>
            <td height="28" valign="top"><table width="685" border="0" align="center" cellpadding="0" cellspacing="0">
                <tbody>
                  <tr>
                    <td valign="top" align="middle" width="12">　</td>
                    <td width="663" valign="top"><table height="31" width="100%">
                        <tbody>
                          <tr>
                            <td height="25" align="right" valign="bottom"><p align="left">
                                <?php// include('member_logininfo.php');?>
                              </p></td>
                          </tr>
                        </tbody>
                      </table>
                      <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" >
                        <tr>
                          <td style="PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 2px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; PADDING-TOP: 5px" width="5%" bgcolor="#E7E7E7"><img src="images/6TMBN72C4XYR`S0AZFS`4Y8.jpg" width="43" height="43" border="0" /></td>
                          <td align="left" bgcolor="#E7E7E7" style="PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 2px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; PADDING-TOP: 5px"><b>支付</b></td>
                        </tr>
                      </table>
                      <br />
<?php
if(!empty($id)){
	$sql="select * from hy_b_order where id='$id' ";
	//echo $sql;exit;
	$objDb->query($sql);
	$row=$objDb->get_data();
	if($row){
		$strorderNum=$row[0]["orderNum"];
		$strallmoney=$row[0]["money"];
	
		$arypname=explode(",",$row[0]["productName"]);
		$arypprice=explode(",",$row[0]["price"]);
		$arybuyNum=explode(",",$row[0]["buyNum"]);
		$arypid=explode(',',$row[0]["productID"]);
	}
?>
                      <div style="border:0px solid #CCC; width:685px;">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" style="padding:10px;" class="sub_order_table_1">
                          <tr>
                            <td bgcolor="#F3F3F3" align="left" colspan="6">订单号：
                              <?=$strorderNum?></td>
                          </tr>
                          <tr>
                            <td width="60" align="left" >产品&nbsp;</td>
                            <td width="177" align="left">产品名称 </td>
                            <td width="125" align="left"><span style="background-color:#f2f2f2;">市场价</span></td>
                            <td width="125" align="left">折扣价</td>
                            <td width="135" align="left">购买数量</td>
                            <td width="63" align="left">小计</td>
                          </tr>
<?php
	for($i=0;$i<count($arypid);$i++){
		$strproductName=$arypname[$i];
		$strprice=$arypprice[$i];
		$strbuyNum=$arybuyNum[$i];
		$strpid=$arypid[$i];
?>
                          <tr class="sub_order_tr_middle">
                            <td width="60" align="left" valign="top"><b>
                              <?=$i+1?>
                              </b></td>
                            <td align="left"><a href="product_detail.php?id='<? echo $strpid; ?>'" target='_blank'><? echo $strproductName; ?></a></td>
                            <td align="left">￥<? echo $strprice;?></td>
                            <td align="left">￥<? echo $strprice;?></td>
                            <td align="left"><? echo $strbuyNum;?></td>
                            <td align="left">￥
                              <? $strprice*$strbuyNum?></td>
                          </tr>
                          <?php
												}
									 ?>
                          <tr>
                            <td colspan="6" align="right">总金额：￥&nbsp;<b>
                              <?=$strallmoney?>
                              </b>&nbsp;</td>
                          </tr>
                        </table>
                      </div>
<?php
 }else{
 ?>
                      <div style="border:1px solid #CCC; width:685px;">
<?php
$sql="select * from hy_b_cars where memberID='".$_SESSION["M_Id"]."' ";
// echo $sql;
//exit;
	$objDb->query($sql);
	$row=$objDb->get_data();
if($row){
	$strallmoney=0;
	$i=0;
	$strpid="";
	$strpnum="";
	$strpname="";
	$strpprice="";
	//产生订单号
	$sql="select (max(id)+1) as maxid from hy_b_cars ";
	$objDb->query($sql);
	$row2=$objDb->get_data();
if($row2){$maxid=$row2[0]["maxid"];}
	$strordernum=date("YmdHis",time()).$maxid;
?>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" style="padding:10px;" class="sub_order_table_1">
                          <tr>
                            <td bgcolor="#F3F3F3" align="left" colspan="6">订单号：
                              <?=$strordernum?></td>
                          </tr>
<?php
foreach($row as $rs){
	$i +=1;
	$strallmoney +=$rs["money"];
	if($strpid==""){$strpid=$rs["productID"];}else{$strpid .=",".$rs["productID"];}
	if($strpnum==""){$strpnum=$rs["buyNum"];}else{$strpnum .=",".$rs["buyNum"];}
	if($strpname==""){$strpname=$rs["productName"];}else{$strpname .=",".$rs["productName"];}
	if($strpprice==""){$strpprice=$rs["price"];}else{$strpprice .=",".$rs["price"];}
?>
                          <tr>
                            <td width="60" align="left" valign="top">产品&nbsp;<b> :</b></td>
                            <td align="left"> 产品名称 </td>
                            <td align="left"><span style="background-color:#f2f2f2;">市场价</span></td>
                            <td align="left">折扣价</td>
                            <td align="left">购买数量</td>
                            <td align="left">小计</td>
                          </tr>
                          <tr class="sub_order_tr_middle">
                            <td width="60" align="left" valign="top" ><b>
                              <?=$i?>
                              </b></td>
                            <td align="left">
							<a href="product_detail.php?id='<?=$rs["productID"]?>'" target='_blank'>
                              <?=$rs["productName"]?>
                            </a>
							</td>
                            <td align="left"><?=$rs["price"]?></td>
                            <td align="left"><?=$rs["price"]?></td>
                            <td align="left"><?=$rs["buyNum"]?></td>
                            <td align="left"><?=$rs["price"]*$rs["buyNum"]?></td>
                          </tr>
<?
		}
		//产生订单
		$strtime=date("Y-m-d H:i:s",time());
		$sql="insert into hy_b_order(`orderNum`,`state`,`memberID`,`memberName`,`productID`,`buyNum`,`productName`,`price`,`money`,`createdate`) values('$strordernum','0','".$_SESSION["M_Id"]."','".$_SESSION["user_name"]."','$strpid','$strpnum','$strpname','$strpprice','$strallmoney','$strtime')";
		//echo $sql;
		//exit;
		$objDb->query($sql);
		$sql="delete from hy_b_cars where memberID='".$_SESSION["M_Id"]."'";
		$objDb->query($sql);
}
else{
	echo "<script>location.href='member_order.php';</script>";
	exit;
}
?>
                          <tr>
                            <td colspan="6" align="right">总金额：&nbsp;<b>
                              <?=$strallmoney?>
                              </b>&nbsp;</td>
                          </tr>
                        </table>
                      </div>
                      <div align="left">
                      <?php
                }
                ?>
                      <div> <br />
                        <span style="font-family:'黑体'; font-size:14px; font-weight:bold; color:#FF0000;">请确认以下您的信息是否正确，如有错误请马上修改,确认支付不可更改！</span><a href="member_info.php"> 修改请点击这里</a><br />
                        <span class="membersure"><br />
                        </span> </div>
                      <div class="sub_order_p"> <b style="font-size:14px;">收货人信息</b><br />
                        收 货 人：<span class="membersure">
                        <?=$strusertruename?>
                        </span><br />
                        收货地址：<span class="membersure">
                        <?=$struseradd?>
                        </span>，<span class="membersure">
                        <?=$struserzipcode?>
                        </span><br />
                        联系电话：<span class="membersure">
                        <?=$strusertel?>
                        </span>，<span class="membersure">
                        <?=$strusermobile?>
                        </span> </div>
                      <div>
                        <form action="" method="post" onsubmit="return checkFrmsss(this);">
                          <div align="center">
                            <input name="orderid" type="hidden" value="<?=$id?>" />
                            <input name="action" type="hidden" value="pay" />
                            <input name="strpid" type="hidden" value="<?=$strpid?>" />
                            <input name="strpnum" type="hidden" value="<?=$strpnum?>" />
                            <input name="strallmoney" type="hidden" value="<?=$strallmoney?>" />
                            <!--     <input name="paytype" type="radio" value="2" checked="checked" />在线支付
                      <input name="paytype" type="radio" value="1" />线下支付-->
                            <br />
                            <br />
                            <input name="submit" type="submit" value="确认支付"  />
                          </div>
                        </form>
                      </div></td>
                  </tr>
                </tbody>
              </table></td>
          </tr>
          <tr>
            <td height="1" background="image/line2.jpg"></td>
          </tr>
        </table>
        <div><img src="images/content_dig.jpg" width="746" height="27" /></div></td>
    </tr>
  </table>
  <?php include("./footer.php"); ?>
</div>
</body>
</html>
